home *** CD-ROM | disk | FTP | other *** search
/ Hacks & Cracks / Hacks_and_Cracks.iso / cracking software / john the ripper v1.3, unix password cracker.zip / DOC.ZIP / JOHN.DOC next >
Text File  |  1997-01-12  |  40KB  |  943 lines

  1.  
  2.     John the Ripper v1.3
  3.    ----------------------
  4.  
  5. ==========================
  6.  What is John the Ripper?
  7. ==========================
  8.  
  9. John the Ripper is a UNIX password cracker, currently available for UNIX
  10. (tested with Linux x86, Solaris 2.x SPARC, OSF/1 Alpha), DOS, WinNT/Win95.
  11.  
  12. I assume that you have already used some UNIX password crackers, so I'll
  13. only describe the things specific to John.
  14.  
  15. ==========
  16.  Overview
  17. ==========
  18.  
  19. John the Ripper is designed to be both powerful and fast. It combines
  20. several cracking modes in one program, and is fully configurable for your
  21. particular needs (you can even code a custom cracking mode using the built
  22. in C compiler). Also, John is available for several different platforms,
  23. which enables you to use the same cracker everywhere (for example even
  24. continue a cracking session that you started on another platform).
  25.  
  26. John's crypt() routine is highly optimized for faster operation, which
  27. makes John run much faster than other crackers. This applies to both the
  28. x86 assembly version, and the portable pure C one.
  29.  
  30. John the Ripper supports the following cracking modes:
  31. - wordlist with or without rules;
  32. - "single crack", makes use of the login/GECOS information;
  33. - incremental, tries all character combinations;
  34. - external, allows you to define your own cracking mode.
  35.  
  36. ================
  37.  How to install
  38. ================
  39.  
  40. With binary distributions, just copy all the files to a separate directory.
  41. Then extract there the common files (supplied in a separate archive). You
  42. might also need a 'chmod +x john' depending on the archive type used.
  43.  
  44. To compile the sources, just enter the directory you extracted them to, and
  45. type 'make'. You'll get a list of systems supported. Select one of those,
  46. or try 'make generic' if your system is not listed. Be sure to use GCC and
  47. GNU make (you might have to type the full path to 'make', since '/bin/make'
  48. is often also present and is not what you need).
  49.  
  50. ============
  51.  How to use
  52. ============
  53.  
  54. I intentionally made John's command line interface be a lot like Cracker
  55. Jack's so that it's easier to start using John for those who have used
  56. Cracker Jack before. Anyway, here's a short description of John's features
  57. including those that are the same as Cracker Jack's.
  58.  
  59. To use John the Ripper, you need to supply it some password files, and a
  60. cracking mode. Cracked passwords will be printed on the screen and saved
  61. in file called ~/john.pot (in this text '~' means John's "home directory",
  62. i.e. the directory you put John's binary in). This file is also used not
  63. to load the accounts you already cracked if you run John again on the same
  64. password file. To retrieve the cracked passwords from ~/john.pot, use the
  65. '-show' option.
  66.  
  67. While cracking, you can press the Enter key for status, or Ctrl+C to abort
  68. the session, saving point information to a file (~/restore by default).
  69. By the way, if you press Ctrl+C twice John will abort immediately without
  70. saving. The point information is also saved every 10 minutes in case of a
  71. crash.
  72.  
  73.  Command line options
  74. ----------------------
  75.  
  76. You can specify some of the following options on John's command line (all
  77. of them are case sensitive, and can be abbreviated):
  78.  
  79.        -pwfile:<file>[,..]     specify passwd file(s) (wildcards allowed)
  80.  
  81. This option is used to specify the password files to be cracked (actually,
  82. anything on the command line that is not starting with a dash will be used
  83. as a password file name).
  84.  
  85.        -wordfile:<file> -stdin wordlist mode, read words from <file> or stdin
  86.  
  87. These are used to enable the wordlist mode.
  88.  
  89.        -rules                  enable rules for wordlist mode
  90.  
  91. Enables rules (like in Crack by Alec Muffett). The rules are stored in
  92. ~/john.ini, in section [List.Rules:Wordlist].
  93.  
  94.        -incremental[:<mode>]   incremental mode [using john.ini entry <mode>]
  95.  
  96. Enables the incremental mode, using the specified ~/john.ini definition
  97. (section [Incremental:<mode>], where <mode> is what you specify on the
  98. command line, [Incremental:All] by default).
  99.  
  100.        -single                 single crack mode
  101.  
  102. Enables the "single crack" mode, using rules from [List.Rules:Single].
  103.  
  104.        -external:<mode>        external mode, using john.ini entry <mode>
  105.  
  106. Enables an external mode, using external functions defined in ~/john.ini's
  107. [List.External:<mode>].
  108.  
  109.        -restore[:<file>]       restore session [from <file>]
  110.  
  111. Continues an interrupted cracking session, reading point information from
  112. the specified file (~/restore by default).
  113.  
  114.        -makechars:<file>       make a charset, <file> will be overwritten
  115.  
  116. Generates a charset file, based on character frequencies from ~/john.pot,
  117. for use with the incremental mode. The entire ~/john.pot will be used for
  118. the charset file unless you specify some password files. You can also use
  119. an external filter() routine with this option.
  120.  
  121.        -show                   show cracked passwords
  122.  
  123. Shows the cracked passwords in a convenient form. You should also specify
  124. the password files.
  125.  
  126.        -test                   perform a benchmark
  127.  
  128. Benchmarks the performance critical routines and prints a table of estimated
  129. cracking speed values for different number of accounts and salts.
  130.  
  131. For those unfamiliar with password crackers internals: xform1() and xform2()
  132. are the actual encryption routines, called for each key/salt pair, while
  133. setkey() is called for each word only, meaning that xform1() or xform2()
  134. (depending on the cracking mode used) are the only routines that will affect
  135. cracking speed if there're enough salts loaded. By the way, setkey() is
  136. benchmarked assuming that words differ by 1 character in length, and 1 more
  137. character replaced -- when using with xform2(), and that passwords are 8
  138. characters long and are totally different (no matching characters) -- when
  139. using with xform1().
  140.  
  141.        -users:<login|uid>[,..] crack this (these) user(s) only
  142.  
  143. Allows you to filter a few accounts for cracking, or for '-show'.
  144.  
  145.        -shells:[!]<shell>[,..] crack users with this (these) shell(s) only
  146.  
  147. This option is useful to crack/show accounts with the required shell only,
  148. or not to crack/show accounts with a bad shell ('!' before a shell name
  149. means 'not'). You can omit the path before a shell name, so '-shells:csh'
  150. will match both '/bin/csh' and '/usr/bin/csh', while '-shells:/bin/csh' will
  151. only match '/bin/csh'.
  152.  
  153.        -salts:[!]<count>       crack salts with at least <count> accounts only
  154.  
  155. This feature sometimes allows to achieve better performance. For example
  156. you can crack only some salts using '-salts:2' faster, and then crack the
  157. rest using '-salts:!2'. Total cracking time will be about the same, but
  158. you will get some accounts cracked earlier, and may not need the rest.
  159.  
  160.        -lamesalts              assume cleartext passwords were used as salts
  161.  
  162. Don't use this option unless you know what you're doing.
  163.  
  164.        -timeout:<time>         abort session after a period of <time> minutes
  165.  
  166. This will cause John to terminate after the specified time has elapsed.
  167.  
  168.        -list                   list each word
  169.  
  170. Prints each word being checked on the standard output. This is useful for
  171. checking if your custom cracking mode works correctly.
  172.  
  173.        -beep -quiet            beep or don't beep when a password is found
  174.  
  175. The default can be altered in ~/john.ini.
  176.  
  177.        -noname -nohash         don't use memory for login names or hash tables
  178.  
  179. You might need these if you don't have enough RAM. Note that '-noname' will
  180. not work with the "single crack" mode, since login names are used while
  181. cracking.
  182.  
  183.  Additional utilities
  184. ----------------------
  185.  
  186. There're some symlinks to John's binary that might also be useful:
  187.  
  188.        xtract [source] [> <target>]
  189.  
  190. Extracts words from a text file (or stdin), to be used as a wordlist. Dupes
  191. are not removed, you'll also need to do a 'sort -u' on the output (in UNIX).
  192.  
  193.        unshadow <passwd> <shadow> [> <target>]
  194.  
  195. Combines the passwd and shadow files (when you already have access to both)
  196. for use with John. You might need this since if you only used shadow file,
  197. the GECOS information wouldn't be used by the "single crack" mode, and also
  198. you wouldn't be able to use the '-shells' option.
  199.  
  200. ================
  201.  Cracking modes
  202. ================
  203.  
  204. The mode descriptions here are short, and only cover the basic things.
  205. You should check the "Customizing" section below for more information.
  206.  
  207.  Wordlist mode
  208. ---------------
  209.  
  210. This is the simplest cracking mode supported by John. All you need is
  211. specify a wordlist (text file containing one word per line), and some
  212. password files. You can enable rules (which are used to modify words) if
  213. desired, they will then be applied to every word in the list.
  214.  
  215. The wordlist should not contain dupes. John doesn't sort the words not
  216. to use too much RAM, since that would require at least loading the entire
  217. wordlist to memory, while now it's read from disk while cracking. Also,
  218. leaving the words order as it is allows you to put frequent words first.
  219. However, if you don't place words in a reasonable order, it is better if
  220. you sort the wordlist alphabetically (John runs a bit faster if each word
  221. it tries only differs from the previous one by a few characters, this is
  222. especially noticable when cracking only a few accounts at a time).
  223.  
  224. However, you shouldn't bother about words longer than 8 characters being
  225. effectively the same password if their first 8 characters match. John can
  226. handle this situation (and only try the password once) if such words are
  227. going one immediately after the other (i.e. when the wordlist is sorted).
  228. You'd better not truncate words to 8 characters in your wordlist, since
  229. the rest may be needed when you use the rules.
  230.  
  231.  "Single crack" mode
  232. ---------------------
  233.  
  234. This is the mode you should start cracking with. It will try using the
  235. login/GECOS information as passwords. Since the information is only used
  236. on the account it was taken from (and on accounts with the same salt,
  237. which takes almost no extra time), "single crack" mode is much faster
  238. than the wordlist mode, which allows using a lot of rules (they are
  239. always enabled for this mode) in a reasonable time. Of course, this will
  240. only get those passwords that are based on the information used.
  241.  
  242. Note that running this mode on many password files at the same time may
  243. sometimes get more accounts cracked than you would get if you ran it on
  244. the files separately.
  245.  
  246. It might be a good idea not to run through all the rules, but specify a
  247. timeout, and then go to other modes. The rules should be sorted by the
  248. number for successful cracks for this case.
  249.  
  250. Cracker Jack users must also note that John's "single crack" mode is
  251. totally different (better) from Jack's. It doesn't require a special
  252. wordlist since the rules support is built into John.
  253.  
  254.  Incremental mode
  255. ------------------
  256.  
  257. This is the most powerful cracking mode, it can try all possible character
  258. combinations as passwords. However, it is assumed that cracking with this
  259. mode will never terminate due to the number of combinations being too large
  260. (actually, it will terminate if you set a low password length limit, or let
  261. it use a small charset), and you'll have to interrupt it earlier.
  262.  
  263. That's why this mode deals with character frequency tables -- to get as many
  264. passwords as possible within a limited time.
  265.  
  266. To use the mode you need a specific definition for the mode's parameters
  267. (including password length limits and the charsets). These parameters are
  268. defined in ~/john.ini's sections called [Incremental:<mode>], where <mode>
  269. is any identifier that you assign to the mode (it's the one you'll have to
  270. specify on John's command line). You can use a pre-defined incremental mode
  271. definition, or define a custom one.
  272.  
  273. Once you have the definition, all you need is specify the incremental mode
  274. option, the mode's identifier and some password files on the command line.
  275.  
  276.  External mode
  277. ---------------
  278.  
  279. You can define an external cracking mode for use with John. This is done
  280. with ~/john.ini's sections called [List.External:<mode>], where <mode> is
  281. any identifier that you assign to the mode. The section should contain some
  282. functions that John will use to generate the words it tries. These functions
  283. are coded in a subset of the C language, and are compiled by John at startup
  284. (if you enable the mode on John's command line).
  285.  
  286. =============
  287.  Customizing
  288. =============
  289.  
  290. John the Ripper's behavior can be customized by editing its configuration
  291. file, ~/john.ini. You can specify defaults for command line options, some
  292. other John's options that are not accessible from its command line, define
  293. parameters for incremental modes, define rules for wordlist and "single
  294. crack" modes, or even define a new cracking mode.
  295.  
  296. The configuration file consists of several sections. Each section starts
  297. with a line containing its name, in brackets. Sections consist of either
  298. value assignments to some variables (in form 'variable = value'), or some
  299. other text specific to particular section's type (names of such sections
  300. start with a 'list.'). Section and variable names are not case sensitive.
  301. Lines starting with '#' or ';' and empty lines are ignored, you can use
  302. them for comments, or to comment out lines that you don't want to delete
  303. completely.
  304.  
  305.  General options
  306. -----------------
  307.  
  308. Defaults for some command line options can be defined in the [Defaults]
  309. section. You can define the following variables:
  310.  
  311. Wordfile   Set to your wordlist file name. This will assume the wordlist
  312.            mode by default - no need to use the '-wordfile' command line
  313.            option unless you want to override this default value.
  314.  
  315. Timeout    Set to the value in minutes. This will enable the timeout for
  316.            all modes by default.
  317.  
  318. Beep       Set to something starting with 'Y' or 'N' (I hope the meaning
  319.            is clear) to specify whether to beep when a password is found or
  320.            not. This default can be overridden with the '-beep' and '-quiet'
  321.            command line options. If you omit this variable definition, the
  322.            default will be not to beep.
  323.  
  324. Some other options can be defined in the [Options] section:
  325.  
  326. Realtime   Set to 'Y' to show elapsed time as D:HH:MM:SS instead of just
  327.            seconds (as Jack does).
  328.  
  329. Percent    Set to 'Y' to show the progress indicator.
  330.  
  331.  Incremental mode parameters
  332. -----------------------------
  333.  
  334. To define the incremental mode parameters you need to create a section
  335. called [Incremental:<mode>], where <mode> is any identifier that you assign
  336. to the mode. There're some pre-defined incremental modes in the default
  337. configuration file supplied with John, you can use them as templates. The
  338. following parameters are supported:
  339.  
  340. CharCount  Allows you to limit the number of different characters used, to
  341.            make John start trying longer passwords earlier. This can also
  342.            expand the charsets to the specified size when using an external
  343.            charset file which only defines less than CharCount characters.
  344.            By default (when this parameter is not defined) all the defined
  345.            characters will be used.
  346.  
  347. MinLen     Minimum password length, in characters (1 by default).
  348.  
  349. MaxLen     Maximum password length, in characters (8 by default).
  350.  
  351. Wordlike   Set to 'Y' to enable a simple built in word filter (words with
  352.            more than one vowel in a row, or more than two non-vowels in a
  353.            row, will get filtered out).
  354.  
  355. File       External charset file name (the file is loaded from ~ unless full
  356.            path is specified). Setting this parameter disables the charsets
  357.            defined inside the configuration file.
  358.  
  359. CharsetNM  (where N and M are digits, 1 <= N <= 8, 1 <= M <= N) Defines a
  360.            charset for password length N, character position M. The order
  361.            of characters is important, more frequent characters should be
  362.            placed first. The charsets don't have to be the same size.
  363.  
  364.  Wordlist rules
  365. ----------------
  366.  
  367. The rules for wordlist and "single crack" modes are defined in separate
  368. sections called [List.Rules:Wordlist] and [List.Rules:Single] respectively.
  369. I used an extended Crack (by Alec Muffett) syntax, since many of you might
  370. be already familiar with it. I added some more rules, and (most important)
  371. a preprocessor, which generates multiple rules from a single source line.
  372. When defining rules, simply place one rule (which may include preprocessor
  373. commands) per line. Each rule consists of one or more simple commands. The
  374. following commands are supported (most of the descriptions are copied from
  375. Crack's dicts.rules, however the code is my own, and is faster than that
  376. from Crack):
  377.  
  378. Ordinary commands:
  379. :       no-op - do nothing to the input word
  380. <n      reject word unless it is < n characters long, where n = 0-9
  381. >n      reject word unless it is > n characters long, where n = 0-9
  382. ^x      prepend character 'x' to word
  383. $y      append character 'y' to word
  384. l       force word to be lowercase
  385. u       force word to be uppercase
  386. c       force word to be capitalized
  387. r       reverse word: "Fred" -> "derF"
  388. d       duplicate word: "Fred" -> "FredFred"
  389. f       reflect word: "Fred" -> "FredderF"
  390. p       make best attempt to pluralize a lowercase word
  391. onx     overstrike character in position n (start at 0) with character 'x'
  392. inx     insert character 'x' in position n (start at 0) and shift the rest
  393.         of the input string right
  394.         nb: if n > strlen(input), character 'x' will be appended
  395. xnm     extract substring from position n (start at 0) for up to m characters
  396.  
  397. Commands which may use character classes:
  398. sxy     replace (swap) all characters 'x' in the word with 'y'
  399. s?cy    replace all characters of class 'c' in the word with 'y'
  400. @x      purge all characters 'x' from the word
  401. @?c     purge all characters of class 'c' from the word
  402. !y      reject word if it contains character 'y'
  403. !?c     reject word if it contains a character in class 'c'
  404. /x      reject word unless it contains character 'x'
  405. /?c     reject word unless it contains a character in class 'c'
  406. =nx     reject word unless character at position n is equal to 'x'
  407. =n?c    reject word unless character at position n is in class 'c'
  408.         nb: the word always starts at position 0
  409.  
  410. Character classes for use in the above commands:
  411. ??      matches '?'
  412. ?v      matches vowels: "aeiouAEIOU"
  413. ?c      matches consonants: "bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ"
  414. ?w      matches whitespace: " \t"
  415. ?p      matches punctuation: ".,:;'\"?!`"
  416. ?s      matches symbols "$%^&*()-_+=|\\<>[]{}#@/~"
  417. ?l      matches lowercase letters ('a' to 'z')
  418. ?u      matches uppercase letters ('A' to 'Z')
  419. ?d      matches digits ('0' to '9')
  420. ?a      matches letters ('a' to 'z' and 'A' to 'Z')
  421. ?x      matches letters and digits ('a' to 'z', 'A' to 'Z' and '0' to '9')
  422. The complement of a class may be matched by the uppercase of its letter,
  423. i.e.: where ?d == DIGITS, ?D == NON-DIGITS, and so on.
  424.  
  425. All the commands described above are the same as in Crack v4.1, while the
  426. following ones are added in John (not very useful, I admit, most of the
  427. required stuff was already implemented in Crack v4.1):
  428.  
  429. {       shift word left: "jsmith" -> "smithj", etc
  430. }       shift word right: "smithj" -> "jsmith", etc
  431. Dn      delete character in position n (start at 0) and shift the rest of
  432.         the input string left
  433. P       "crack" -> "cracked", etc (lowercase only)
  434. G       "crack" -> "cracking", etc (lowercase only)
  435. ~i      invert case, by keyboard: "Crack96" -> "cRACK(^", etc
  436. ~I      invert case: "Crack96" -> "cRACK96", etc
  437. ~v      lowercase vowels: "Crack96" -> "CRaCK96", etc
  438. ~>      shift each character right, by keyboard: "Crack96" -> "Vtsvl07", etc
  439. ~<      shift each character left, by keyboard: "Crack96" -> "Xeaxj85", etc
  440.  
  441. Extra "single crack" mode commands for word pairs support, to control if
  442. other commands are applied to the first, second, or both words:
  443.  
  444. 1       first word only
  445. 2       second word only
  446. +       the concatenation of both (should only be used after a '1' or '2')
  447.  
  448. If you use some of the above commands in a rule, it will only process word
  449. pairs (full names, from the GECOS information), and reject single words.
  450. A '+' is assumed at the end of any rule that uses some of these commands,
  451. unless you specify it manually. For example, '1l2u' will convert the first
  452. word to lowercase, the second one to uppercase, and use the concatenation
  453. of both. The use for a '+' might be to apply some more commands: '1l2u+r'
  454. will reverse the concatenation of both words, after applying some commands
  455. to them separately.
  456.  
  457. [ Crack v5.0 wasn't out by the time I was coding rule support for John, so
  458. I extended the syntax my own way. Actually, the new Crack v5.0's rules seem
  459. redundant, or match with what I already added to John ([ == D0, ] == rD0r,
  460. C == c~I, t == ~I, (x == =0x, )x == r=0xr, 'n == x0n). The only rule left
  461. is %nx, or %n?c (rejects the word unless it contains at least n instances
  462. of character 'x', or of members of class 'c'). Anyway, I added all these to
  463. John, for compatibility reasons. Be sure to prefix '[' and ']' with a '\'
  464. if you use them, since they're control characters for the preprocessor. ]
  465.  
  466. If a rule (line of commands) doesn't change a word, it is rejected, unless
  467. the entire rule was a plain ':'. This assumes you have a ':' somewhere in
  468. your rules list.
  469.  
  470. The preprocessor is used to combine similar rules into one source line. For
  471. example, if you need to make John try lowercased words with digits appended,
  472. you could write a rule for each digit, 10 rules total. Now imagine appending
  473. two-digit numbers -- the configuration file would get large and ugly.
  474.  
  475. With the preprocessor you can do these things easier. Simply write one
  476. source line containing the common part of these rules, and the list of
  477. characters you would have put into separate rules, in brackets (the way
  478. you would do in a regular expression). The preprocessor will then generate
  479. the rules for you (at John's startup). For the examples above, the source
  480. lines will be 'l$[0-9]' (lowercase and append a digit) and 'l$[0-9]$[0-9]'
  481. (lowercase and append two digits). These source lines will be expanded to
  482. 10 and 100 rules respectively. By the way, the preprocessor's commands are
  483. processed right-to-left, and the characters are processed left-to-right,
  484. which gets a normal order of numbers in such cases as in the example with
  485. appending two-digit numbers. Note that I only used character ranges in these
  486. examples, however you can combine them with character lists, like '[aeiou]'
  487. will use vowels, and '[aeiou0-9]' will use vowels and digits.
  488.  
  489. There're some control characters in rules ('[' starts a preprocessor's
  490. character list, '-' marks a range inside the list, etc). You should prefix
  491. them with a '\' if you want to put them inside a rule without using their
  492. special meaning. Of course, the same applies to '\' itself. Also, if you
  493. need to start a preprocessor's character list at the very beginning of a
  494. line, you'll have to prefix it with a ':', or it would be treated as a new
  495. section start.
  496.  
  497.  Defining an external mode
  498. ---------------------------
  499.  
  500. To define an external cracking mode you need to create a section called
  501. [List.External:<mode>], where <mode> is any identifier that you assign to
  502. the mode. The section should contain some functions that are coded in a
  503. subset of the C language. John will compile and use them if you enable the
  504. mode on its command line. The compiler produces virtual machine code which
  505. is then either interpreted or converted into machine executable code (this
  506. is currently done for x86 hardware only).
  507.  
  508. The following functions are currently used by John:
  509.  
  510. init()     called at startup, should initialize global variables
  511. filter()   called for each word to be tried, can filter some words out
  512. generate() called to generate words, when no other cracking modes used
  513. restore()  called when restoring an interrupted session
  514.  
  515. All of them are of type 'void', with no arguments, and should use global
  516. variable 'word' (which is pre-defined as 'int word[9]'), except for init()
  517. which is called before 'word' is initialized. The 'word' variable contains
  518. current word to be tried, in ASCIIZ. filter() can modify it, or zero out
  519. 'word[0]' to skip it. generate() shouldn't assume any particular value of
  520. 'word' when it gets called, but should put there the next word to be tried,
  521. or zero out 'word[0]' when cracking is complete (this will cause John to
  522. terminate). restore() should set global variables to continue from the
  523. supplied 'word'.
  524.  
  525. You can either use an external mode separately, or with some other cracking
  526. mode, in which case only init() and filter() will be used (and only filter()
  527. will be required). Using an external filter is compatible with all the other
  528. cracking modes and '-makechars' command line option.
  529.  
  530. It is recommended that you don't use filter(), or at least don't filter too
  531. many words out when using an external mode with your own generate(). Better
  532. modify generate() not to generate words that would get filtered out.
  533.  
  534. As I already mentioned above, the compiler supports a subset of C. John is
  535. a cracker, not a compiler, so I don't think it needs anything else. Here's
  536. a list of C features that are missing in John's compiler:
  537.  
  538. - only standard functions supported, you can't define your own ones;
  539. - only 'while' loops are supported;
  540. - only 'int' and 'void' data types supported;
  541. - only single dimensional arrays supported;
  542. - structs/unions are not supported;
  543. - pointers are not supported (right, more about arrays below);
  544. - probably something else...
  545.  
  546. Some of the supported features differ from those of C:
  547.  
  548. - array name alone refers to its first element (the one with zero index),
  549.   not the array's address;
  550. - '++' and '--' operations are performed while the expression is being
  551.   calculated, not pre/post-calculated; this will give the same result as in
  552.   C in most cases (like 'i = j++;' is equal to 'i = j; j = j + 1;' in both
  553.   C and John's compiler), but if the variable these operations are applied
  554.   to is used more than once in one expression, the result will differ from
  555.   that of C (like 'i = j++ - j++;' is equal to 'i = j - (j + 1); j = j + 2;'
  556.   in John's compiler, but 'i = j - j; j = j + 2;' in C);
  557. - I hope nothing else differs...
  558.  
  559. However, the powerful C expression syntax (all the integer operations),
  560. 'if'/'else' and 'while' are still available for use. It should be enough
  561. for coding almost anything. You can use the external mode example in the
  562. configuration file supplied with John as a template.
  563.  
  564. ================
  565.  Usage examples
  566. ================
  567.  
  568. These examples are to give you some tips on what John's features can be
  569. used for. Some of them may not be obvious, I'm sorry if others are, but
  570. anyway, I just got tired of answering questions.
  571.  
  572.  Command line
  573. --------------
  574.  
  575. 1. Assume you just got a password file, 'passwd.1', and want to crack it.
  576. It is wise to start with the "single crack" mode:
  577.  
  578.    john -single passwd.1
  579.  
  580. or, since options can be abbreviated (however, I'll be using full names for
  581. most options in these examples):
  582.  
  583.    john -si passwd.1
  584.  
  585. If you have more files to crack, better to load them at the same time:
  586.  
  587.    john -single passwd.1 passwd.2
  588.  
  589. or even:
  590.  
  591.    john -single passwd.*
  592.  
  593. 2. Now, you got some passwords cracked, they are saved in ~/john.pot. You
  594. want to retrieve them:
  595.  
  596.    john -show passwd.1
  597.  
  598. If the account list gets large and doesn't fit on the screen, you can of
  599. course use output redirection, like:
  600.  
  601.    john -show passwd.1 | more
  602.  
  603. Now, you may notice that many accounts have a disabled shell, you can make
  604. John ignore these (assume that shell is called '/etc/expired'):
  605.  
  606.    john -show -shells:!/etc/expired passwd.1
  607.  
  608. or, shorter, but will also match '/any/path/expired':
  609.  
  610.    john -show -shells:!expired passwd.1
  611.  
  612. or, if you also want to ignore some other shell, say '/etc/newuser':
  613.  
  614.    john -show -shells:!expired,!newuser passwd.1
  615.  
  616. To check if any root (uid 0) accounts cracked:
  617.  
  618.    john -show -users:0 passwd.1
  619.  
  620. or, to check for cracked root (uid 0) accounts in all the files:
  621.  
  622.    john -show -users:0 passwd.*
  623.  
  624. To display the root (login 'root') account only:
  625.  
  626.    john -show -users:root passwd.1
  627.  
  628. 3. When the "single crack" mode doesn't give enough accounts, you can use
  629. more powerful cracking modes, like the wordlist one. Assume your wordlist
  630. file is called 'words.lst':
  631.  
  632.    john -w:words.lst passwd.1
  633.  
  634. or, with rules enabled (slower, but more powerful):
  635.  
  636.    john -w:words.lst -rules passwd.1
  637.  
  638. To only crack accounts with a good shell (in general, both the '-shells'
  639. and '-users' filters described above work for all the cracking modes also):
  640.  
  641.    john -w:words.lst -rules -shells:sh,csh,tcsh,bash passwd.1
  642.  
  643. Like with all the other cracking modes, faster to crack all the files you
  644. need cracked simultaneously:
  645.  
  646.    john -w:words.lst -rules passwd.*
  647.  
  648. You can crack some accounts only. This will try cracking all root (uid 0)
  649. accounts in all the password files:
  650.  
  651.    john -w:words.lst -rules -users:0 passwd.*
  652.  
  653. However, I don't recommend cracking root passwords only, since it usually
  654. takes longer to crack the password (often impossible within a reasonable
  655. time) than to hack root using security holes. If you are cracking your own
  656. password file to ensure the passwords are uncrackable, better select a good
  657. root password, and only crack the rest.
  658.  
  659. Sometimes it is useful to split your password files into two parts which
  660. you crack separately, like:
  661.  
  662.    john -w:words.lst -rules -salts:2 passwd.*
  663.    john -w:words.lst -rules -salts:!2 passwd.*
  664.  
  665. This will make John try salts with two or more accounts faster, and then
  666. try the rest. Total cracking time will be about the same, but you will get
  667. some accounts cracked earlier, and may not need the rest. Also, you might
  668. want to try all the accounts with a small wordlist, and only those that you
  669. can try faster (with '-salts:2') with a larger one. Often it is better to
  670. use a larger value than 2 for '-salts' (sometimes even as high as 1000 will
  671. do), adjust it for your particular case.
  672.  
  673. Note that the default wordlist rules include ':' (which means 'try words
  674. as they are in the list') as the first line. If you already ran through a
  675. wordlist without using rules, and then decided to try the same wordlist
  676. with rules also, you'd better comment this line out.
  677.  
  678. 4. The most powerful cracking mode in John is incremental. You can simply
  679. run:
  680.  
  681.    john -i passwd.1
  682.  
  683. This will use the default incremental mode parameters, which are defined in
  684. ~/john.ini's [Incremental:All] section. In the configuration file supplied
  685. with John these parameters are to use the full 95 character charset, and to
  686. try all possible password lengths, from 1 to 8 characters. Don't expect this
  687. to terminate in a reasonable time (unless all the passwords were weak and
  688. got cracked).
  689.  
  690. In many cases it is faster to use some other pre-defined incremental mode
  691. parameters and only crack simpler passwords, from a limited charset. The
  692. following command will try 26 different characters only, passwords from
  693. 'a' to 'zzzzzzzz':
  694.  
  695.    john -i:alpha passwd.1
  696.  
  697. Again, you can crack root accounts only and use some other John's features
  698. with the incremental mode. This command will try cracking all root (uid 0)
  699. accounts in all the password files, and only those of them that produce
  700. matching salts, so you get at least twice the performance -- if you have a
  701. lot of password files (like 1000 of them, named '*.pwd'), otherwise there
  702. will be no roots with matching salts:
  703.  
  704.    john -i -users:0 -salts:2 *.pwd
  705.  
  706. 5. If you got a password file and already have a lot of accounts cracked
  707. and/or sniffed (but need some more), and the passwords are unusual, then
  708. you might want to generate a new charset file, based on characters from
  709. that password file only:
  710.  
  711.    john -makechars:custom.chr passwd.1
  712.  
  713. Then use that new file for the incremental mode.
  714.  
  715. If you got several password files from the same country, it might be useful
  716. to use all of them for the charset file that you then use to crack more
  717. accounts in these files or some other password files from that country:
  718.  
  719.    john -makechars:custom.chr passwd.1 passwd.2
  720.    <add your custom incremental mode definition to ~/john.ini>
  721.    john -i:custom passwd.3
  722.  
  723. In the example above, I assume that 'passwd.1' and 'passwd.2' are password
  724. files from the same country that you already have a lot of accounts for,
  725. and 'passwd.3' is the password file you need cracked.
  726.  
  727. You can use some pre-defined or custom word filters when generating the
  728. charset file, to make it only try some simpler words:
  729.  
  730.    john -makechars:my_alpha.chr -external:filter_alpha passwd.1
  731.  
  732. If your ~/john.pot file got large enough (or if you don't have any charset
  733. files at all), you might want to use it for the new charset files:
  734.  
  735.    john -makechars:all.chr
  736.    john -makechars:alpha.chr -external:filter_alpha
  737.    john -makechars:digits.chr -external:filter_digits
  738.  
  739. In the example above, John will overwrite the charset files (if they already
  740. exist) with the ones based on your entire ~/john.pot (John uses the entire
  741. file if you don't specify any password files). Note that the word filters
  742. used are pre-defined in ~/john.ini supplied with John for your convenience.
  743.  
  744.  Configuration file
  745. --------------------
  746.  
  747. 1. Assume you notice that in some password file a lot of users have their
  748. passwords set to login names with '?!' appended. Then you just make a new
  749. "single crack" mode rule, and place it somewhere in the beginning:
  750.  
  751.    [List.Rules:Single]
  752.    $?$!
  753.  
  754. Hint: if you want to temporary comment out all the default rules, you can
  755. simply rename the section to something John doesn't use, and define a new
  756. one with its old name, but be sure to leave the 'list.' part of the name,
  757. so you don't get a parse error.
  758.  
  759. All the same applies to the wordlist rules also.
  760.  
  761. 2. If you generate a custom charset file (described above) you will also
  762. need to define a ~/john.ini section with the incremental mode parameters.
  763. In the simplest case it will be like this (where 'Custom' can be replaced
  764. with any name you like):
  765.  
  766.    [Incremental:Custom]
  767.    File = custom.chr
  768.  
  769. This will make John use characters that were in passwords used to generate
  770. the charset file only. If you want to use all the 95 characters, you will
  771. also need to add:
  772.  
  773.    CharCount = 95
  774.  
  775. Adding this line will tell John to expand the charsets if some of the 95
  776. characters (ASCII codes 32 to 126) didn't occur while generating the file.
  777. The characters are added in that order: a-z, A-Z, 1-9, 0, the rest.
  778.  
  779. You can also use CharCount to limit the number of different characters that
  780. John tries:
  781.  
  782.    CharCount = 25
  783.  
  784. If you didn't use any filters when generating the charset file, setting
  785. CharCount that low will most likely disable some rare characters, and make
  786. John try complicated long passwords earlier.
  787.  
  788. To make John try passwords of some lengths only, use the following lines:
  789.  
  790.    MinLen = 6
  791.    MaxLen = 8
  792.  
  793. Setting 'MinLen' high, as in the example above, is reasonable if shorter
  794. passwords weren't allowed to set on the machine you got the password file
  795. from (however, note that root can usually set any password for any user).
  796.  
  797. On the contrary, you might want to set 'MaxLen' low if you think there are
  798. enough short passwords.
  799.  
  800. When using alphabetical characters only, it may be useful to enable the
  801. simple built in word filter, if many passwords are simple enough:
  802.  
  803.    [Incremental:Wordlike]
  804.    CharCount = 26
  805.    MinLen = 3
  806.    Wordlike = Yeah
  807.    File = alpha.chr
  808.  
  809. 3. When using John on machines with only 4Mb (or less) of RAM installed, you
  810. may need to use smaller charsets, since the ones generated with '-makechars'
  811. require a lot of memory when expanded (for faster operation). You might also
  812. need this if you load a lot of password files, and don't have enough memory
  813. left, or to make John run a little faster when cracking only a few (or one)
  814. salt. This happens because John can take the advantage of each word it tries
  815. being like the previous one, with only some characters changed. When it uses
  816. large external charset files, the words are tried in a different order than
  817. when using smaller charsets inside of ~/john.ini, and are too different from
  818. each other. However, note that a little increase of comparisons/second does
  819. not always mean you get your passwords cracked faster, the better order of
  820. tries when using the larger external charsets is also important. So it is
  821. wise to only use the smaller charsets if there's no other choice, or if you
  822. will be trying all the character combinations anyway.
  823.  
  824. I intentionally left the smaller charsets inside of ~/john.ini supplied with
  825. John so you can just comment out the 'File =' lines, and they will be used
  826. instead of the large external ones.
  827.  
  828. 4. Another use of the smaller charsets may be to define them manually for
  829. some special cases. For example, if you know a place where users often
  830. suffix their passwords with '1':
  831.  
  832.    [Incremental:Suffix1]
  833.    MinLen = 6
  834.    MaxLen = 6
  835.    Charset61 = abcdefghijklmnopqrstuvwxyz
  836.    Charset62 = abcdefghijklmnopqrstuvwxyz
  837.    Charset63 = abcdefghijklmnopqrstuvwxyz
  838.    Charset64 = abcdefghijklmnopqrstuvwxyz
  839.    Charset65 = abcdefghijklmnopqrstuvwxyz
  840.    Charset66 = 1
  841.  
  842. Of course, you can do the same for other lengths. It is also wise to sort
  843. the characters by their frequencies. If you're too lazy to actually do that,
  844. you can simply take the charsets from a pre-defined incremental mode. For
  845. example, if you take Charset61 to 65 in the example above from the default
  846. [Incremental:Alpha] definition's Charset51 to 55, you will get almost what
  847. you would get if calculating the frequencies for 6 character long passwords
  848. with first 5 characters being alphabetical, and '1' at the end.
  849.  
  850. 5. You can do the same thing as in the example above by coding an external
  851. word filter:
  852.  
  853.    [List.External:Filter1]
  854.    void filter() {
  855.      int i;
  856.  
  857.      i = 0;
  858.      while (word[i] && word[i] >= 'a' && word[i] <= 'z') i++;
  859.      if (word[i] != '1' || word[i + 1]) word = 0;
  860.    }
  861.  
  862. This filter will only leave words with some alphabetical characters and '1'
  863. at the end. You can now use it with some other cracking modes, but this will
  864. most likely be slow, since most words will get filtered out. Better to use
  865. it for generating the charsets, and use them (if you have enough passwords
  866. cracked that will pass the filter).
  867.  
  868. If you can't use the frequency tables for some reason, you can do the same
  869. by coding a totally new external mode:
  870.  
  871.    [List.External:Suffix1]
  872.    int len, current[9];
  873.  
  874.    void init() {
  875.      int i;
  876.  
  877.      current[len = 6] = 0; current[i = len - 1] = '1';
  878.      while (i--) current[i] = 'a';
  879.    }
  880.  
  881.    void generate() {
  882.      int i;
  883.  
  884.      i = len + 1;
  885.      while (i--) word[i] = current[i];
  886.  
  887.      i = len - 2;
  888.      while (++current[i] > 'z')
  889.      if (i) current[i--] = 'a'; else current = -1;
  890.    }
  891.  
  892.    void restore() {
  893.      int i;
  894.  
  895.      i = len + 1;
  896.      while (i--) current[i] = word[i];
  897.    }
  898.  
  899. =========
  900.  Credits
  901. =========
  902.  
  903. While developing John, I used some ideas from other password crackers:
  904.  
  905. - Crack by Alec Muffett --
  906.     wordlist rules syntax;
  907. - Cracker Jack by Jackal --
  908.     user interface;
  909. - Star Cracker by The SOrCErEr --
  910.     thanks for proving the large charset files are worth implementing.
  911.  
  912. The crypt() routine is based on the old one by Alec Muffett, that came
  913. with Crack v4.1. Only some initialization routines (which are not time
  914. critical) remained almost unchanged now, the rest is re-coded using my
  915. own ideas and some from other crypt() implementations (actually, there
  916. are now several different algorithms supported with #ifdef's to better
  917. match your architecture).
  918.  
  919. I'd like to thank Roman Rusakov for the x86 assembly version of crypt()
  920. that my implementation is based on. His optimization hints are great.
  921.  
  922. The DOS version is compiled with DJGPP v2 by DJ Delorie with GCC 2.7.2
  923. (http://www.delorie.com), the DPMI server is by Charles W Sandmann
  924. (sandmann@clio.rice.edu; 1206 Braelinn, Sugar Land, TX 77479), its source
  925. code is at ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2misc/csdpmi3s.zip.
  926.  
  927. Cygnus Developer's Kit (http://www.cygnus.com/gnu-win32) was used to compile
  928. the Win32 version.
  929.  
  930. ========================
  931.  How can I contact you?
  932. ========================
  933.  
  934. Send your mail to solar@ideal.ru or 2:5020/398.9, or catch me on EFnet IRC,
  935. my nick is Solar_Diz.
  936.  
  937. Please, don't ask me questions until you read this entire file (and some
  938. FAQs on password cracking in general, if you're unfamiliar with it). Also,
  939. do not send me password files, I'm not a cracking service.
  940.  
  941. Signed,
  942. Solar Designer
  943.